import React, { useState, useEffect } from 'react';
import { useSnapshot } from 'valtio'
import store from '@/store';

const Home: React.FC = () => {
  const { count } = useSnapshot(store.home);
  let [ num, setNum] = useState(0);
  const increase = () => {
    setNum(num + 1);
  };
  useEffect(() => {
    console.log(num);
    store.home.increase(num);
  }, [num]);
  return (
    <div>
      <div onClick={increase}>加1</div>
      { count }
      <div onClick={() => store.home.decrease() }>减1</div>
    </div>
  );
};

export default Home;